﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;

namespace ProjectBase.Core
{
    /// <summary>
    ///     filter object represents the base definiton of filters
    ///     to be used for handling the Entity's list.
    /// This common interface grants the same approach for filtering, ordering, paging... for all entities.
    /// TID template represents ID type of the managed Entity.
    /// </summary>
    /// <typeparam name = "TID"></typeparam>
    public interface IFilter<TID> : IFilter
    {
        /// <summary>
        ///     Keeps the list of IDs of current page.
        ///     The ID of current item can be then found in this list -
        ///     That allows to quickly find out next or previous item
        /// </summary>
        IList<TID> ItemPositionInList { get; set; }

        /// <summary>
        ///     Sets the ID. It is up to implementor, how the null state is handled.
        ///     While id of type(string) can have null, structs (int, long) has default value 0,
        ///     which does not implicate that user is filtering for ID == 0.
        ///     That's why TID ID property is not introduced here.
        /// </summary>
        /// <param name="idSearch"></param>
        void SetIdSearch(TID idSearch);
    }

    /// <summary>
    ///     filter object represents the base definiton of filters
    ///     to be used for handling the Entity's list.
    /// This common interface grants the same approach for filtering, ordering, paging... for all entities.
    /// </summary>
    public interface IFilter : ICloneable
    {
        /// <summary>
        ///     Total count of all rows matching filtering criteria.
        /// (Readonly - generated value, should be provided by Dao.Find()).
        /// </summary>
        int TotalRowCount { get; set; }

        /// <summary>
        ///     SET Maximum rows count on a page.
        ///     In fact this value is always set, by default to 20.
        ///     In cases when the target is to find any - set it to 1.
        ///     When you want all records, set it to int.MaxValue
        /// </summary>
        int MaxRowsPerPage { get; set; }

        /// <summary>
        ///     Paging. This value is maintained by base controller
        ///     and keeps information about which is the currently navigated page
        /// </summary>
        int CurrentPage { get; set; }

        /// <summary>
        ///     Keeps the current Item number (position in the list)
        ///     to allow paging base on single Item!
        /// </summary>
        int CurrentRow { get; set; }

        /// <summary>
        ///     The counted value! Allows to display on UI how many pages is in the storage
        /// </summary>
        int PageCount { get; }

        /// <summary>
        ///     Collection for sorting criteria.
        /// </summary>
        IDictionary<string, bool> OrderBy { get; set; }

        /// <summary>
        ///     The list of properties to be selected for the List view (Find)
        ///     If empty, then Criteria.List&lt;T&gt;() is called.
        ///     If at least one pair exists, the PropertyList Restriction is applied
        ///     And the SQL Select statement returnes only selected pairs.
        ///     The key is the property name ("Code", "Address.City").
        ///     If the value is not null, then it should mean the resulting entity property to be filled:
        ///     e.g. ["Address.City", "City"] means, that "Address.City" key is transfered to "City" property of current entity.
        ///     the City could be only virtual (not persisted) e.g. string City { get; protected set; }
        /// </summary>
        IDictionary<string, string> PropertyList { get; set; }

        /// <summary>
        ///     Smart switch informing if the filter criteria are filled (binded from the form)
        ///     Or empty (just created and not binded yet)
        /// </summary>
        bool HasDefaultValues { get; set; }

        /// <summary>
        ///     If there is non empty value, then edit anchor on List view
        ///     will target this window (list will be displayed in one window
        ///     and detail+edit in another window)
        ///     This value is set to IListModel on every OnBeforeList() operation
        /// </summary>
        string TargetNameForLink { get; set; }

        /// <summary>
        ///     allowes to provide information about the
        ///     MasterPage, which should be used for this link.
        ///     (For example when the Target is different, and detail should be only with body and buttons)
        ///     Default should be string.Empty, meaning the default MasterPage to be used
        /// </summary>
        string TargetMasterPageForLink { get; set; }

        /// <summary>
        ///     This collection is used to render combobox on the filter screen
        ///     with the options of available MasterPages.
        ///     User can select, which one will be used for the detail view.
        ///     If this list is empty, WebControl should not be rendered at all
        /// </summary>
        IDictionary<string, string> MasterPageOptionsList { get; set; }

        /// <summary>
        ///     Export to Excel setting.
        ///     This switch (when set to true) allows exporting of all selected records,
        ///     (hiding the MaxRows restriciton).
        ///     By default set to true in the 'OnBeforeListToExcel()'
        /// </summary>
        bool ExportAllRows { get; set; }

        /// <summary>
        ///     By default returns true if: some nullable ValueType has value;
        ///     or some string value ending with "Exact" has value;
        ///     or some other string value IsNotEmpty();
        ///     or some inner IFilter.IsFilled();
        ///     or some IPersistentObject property Is();
        /// </summary>
        /// <returns></returns>
        bool IsFilled();
    }
}